<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>domContains</title>
</head>

<body>
    <div id="app">
        <p id="child">p元素是app元素的子元素，打开控制台可以查看验证结果。</p>
    </div>
    <div id="next">兄弟元素</div>
    <script>
        const domContains = (parent, child) => Boolean(0x10 & parent.compareDocumentPosition(child));
        const child = document.querySelector('#child');
        const parent = document.querySelector('#app');
        const next = document.querySelector('#next');
        console.log(domContains(parent, child), domContains(parent, parent), domContains(parent, next))
    </script>
</body>

</html>